<template>
  <div class="pay-result">
	<image class="line" src="https://jtmc.oss-cn-hangzhou.aliyuncs.com/wmp/common/i_pay_finish.png" mode="widthFix"></image>
    <div class="text">支付成功</div>
	<view class="hc">
		
	</view>
	<view class="text-line">
		已完成支付?点击此按钮返回上一页面
	</view>
	<view class="btn" @click="JumpToHome">
		返回商家
	</view>
  </div>
</template>


<script setup>
import { onMounted } from "vue";
import setting from "@/common/config.js"; 
// 微信商家小票
const wxInit = () => {
  //初始化小票
  var initData = {
    action: "onIframeReady",
    displayStyle: "SHOW_CUSTOM_PAGE",
  };
  var initPostData = JSON.stringify(initData);
  parent.postMessage(initPostData, "https://payapp.weixin.qq.com");
};
onMounted(() => {
  wxInit();
});
//注册点击事件(去首页)
const JumpToHome = () => {
	const link = uni.getStorageSync('wxlink')
	let homePage = `${setting.APP_PATH}pages/home/index`
	switch (link) {
		case 'order': // 点单 跳转订单页
			homePage = `${setting.APP_PATH}pages/order/index`
			break;
		case 'store': // 储值 跳转储值页
			homePage = `${setting.APP_PATH}pages/my/index`
			break;
		case 'memberUp': // 会员升级 跳转个人中心
			homePage = `${setting.APP_PATH}pages/my/index`
			break;
		default:
			homePage = `${setting.APP_PATH}pages/home/index`
			break;
			
	}
	
	  var mchData = {
		action: "jumpOut",
		jumpOutUrl: homePage, //跳转的页面
	  };
	  var postData = JSON.stringify(mchData);
	  parent.postMessage(postData, "https://payapp.weixin.qq.com");
};
</script>

<style lang="less" scoped>
.pay-result {
  height: 100vh;
  width: 100vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 40px;
  background-color: #FFFFFF;
  .text {
    font-family: PingFang SC;
    font-weight: 500;
    font-size: 32rpx;
    color: #212121;
    line-height: 64rpx;
  }
}
.line{
	width: 100rpx;
	height: 100rpx;
}
.hc{
	height: 169rpx;
	width: 100%;
}
.btn{
	width: 320rpx;
	height: 80rpx;
	background: var(--dt-backcolorPink);
	border-radius: 40rpx;
	text-align: center;
	font-family: PingFang SC;
	font-weight: bold;
	font-size: 32rpx;
	color: #FFFFFF;
	line-height: 80rpx;
}
.text-line{
	font-family: PingFang SC;
	font-weight: 500;
	font-size: 24rpx;
	color: #666666;
	line-height: 42rpx;
	padding-bottom: 12rpx;
}
</style>

